package orz.itrip.biz.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import orz.itrip.DtoUtils;
import orz.itrip.biz.service.HotelRoomService;
import orz.itrip.biz.vo.GetRoomVo;
import orz.itrip.dto.Dto;
import orz.itrip.pojo.HotelRoom;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/api/hotelroom")
@Api(tags = "酒店",description = "文档说明",hidden = true)
public class HotelRoomController {

    @Resource
    private HotelRoomService hotelRoomService;

    @GetMapping(value = "getimg/{hotelId}",headers = "token")
    @ApiOperation(value = "获取酒店图片",notes = "获取对应的酒店图片")
    public Dto getimg(@PathVariable(value = "hotelId") Long hotelId, HttpServletRequest request){
        if (!StringUtils.isEmpty(request.getHeader("token"))) {
            return hotelRoomService.getimg(hotelId);
        }
        return DtoUtils.getFalseDto("token失效，请重登录","100000");
    }

    @GetMapping(value = "queryhotelroombed",headers = "token")
    @ApiOperation(value = "获取酒店床型",notes = "获取酒店床型")
    public Dto queryhotelroombed(HttpServletRequest request){
        if (!StringUtils.isEmpty(request.getHeader("token"))) {
            return hotelRoomService.queryhotelroombed();
        }
        return DtoUtils.getFalseDto("token失效，请重登录","100000");
    }

    @PostMapping(value = "queryhotelroombyhotel",headers = "token")
    @ApiOperation(value = "获取酒店床型",notes = "获取酒店床型")
    public Dto queryhotelroombyhotel(@RequestBody GetRoomVo getRoomVo, HttpServletRequest request){
        if (!StringUtils.isEmpty(request.getHeader("token"))) {
            return hotelRoomService.queryhotelroombyhotel(getRoomVo);
        }
        return DtoUtils.getFalseDto("token失效，请重登录","100000");
    }
}
